using System;
using System.Collections.Generic;
using System.Text;

namespace RecoFace
{
    using WebCam_Capture;
    using System.Windows.Forms;

    public class Camera
    {
        // Variable of WebCamCapture class
        private WebCamCapture Cam;
        private FrmMain Parent;
        PictureBox PicFi;

        //Initialize camera
        public void Init_Cam(FrmMain form, int W, int H, PictureBox picFisrt)
        {
            Parent = form;
            PicFi = picFisrt;

            Cam = new WebCamCapture();
            Cam.CaptureHeight = H; // set camera height
            Cam.CaptureWidth = W; // set camera width

            Cam.TimeToCapture_milliseconds = 1; // refresh picture after avery one milli seconds
            Cam.ImageCaptured += Cam_ImageCaptured; // get picture from camera
        }

        public void Start()
        {
            Cam.Start(0); // starting capture
        }

        // Get picture of camera. Set picCam equal camera image
        public void Cam_ImageCaptured(object source, WebcamEventArgs e)
        {
            PicFi.Image = e.WebCamImage; // set image to picturebox
        }
    }
}